public class Problem3 {
	public static void main(String[] args) {
		long M = 600851475143L;
		long p = 2;

		long m = 1;

		while (M != 1) {
			while (M != 1 && M % p == 0) {
				M /= p;
				m *= p;
				if (m > M) {
					System.out.println("optimized: " + M);
					return;
				}
			}

			if (M == 1) {
				System.out.println("" + p);
			} else
				p = next_prime(p);
		}
	}

	private static long next_prime(long p) {
		long i = p;

		while (true) {
			i++;
			
			long j = 2;
			for (; j <= Math.sqrt(i); ++j) {
				if (i % j == 0)
					break;
			}

			if (i % j == 0)
				continue;

			return i;
		}
	}

	
}
